def run(mainLocation):
    import os
    if os.environ['QL_DIR'] == '':
        print('ERROR: Environment variable "QL_DIR" not defined!')
        return
    if os.environ['QT_DIR'] == '':
        print('ERROR: Environment variable "QT_DIR" not defined!')
        return
    loc = mainLocation + 'QuantLibExtensions\\SWIG'
    try:
        retvalue = os.system('swig -python -c++ -modern ' + '-I%s ' % os.environ['QL_DIR'] + '-I%s ' % os.environ['QT_DIR'] + '%s\\quantlib.i' % loc)
    except:
        print('ERROR: Problem with SWIG...')
        return
    print(retvalue)

if __name__ == '__main__':
    import sys, os
    run(os.path.dirname(os.path.dirname(sys.path[0])) + '\\')